﻿@model XT.Exam.MODEL.Student
@using XT.Exam.MODEL
@{
    ViewBag.Title = "leadingin";
}
<title>导入学生信息</title>
<h2>上传学生信息</h2>
<link href="~/Content/static/h-ui/css/H-ui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="~/Content/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="~/Content/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="~/Content/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="~/Content/static/h-ui.admin/css/style.css" />

@using (Html.BeginForm("Browse", "SysUserInfo", FormMethod.Post, new { enctype = "multipart/form-data", id = "form_Upload" }))
{
    <div class="input-group" style="width:920px;float:left">
        @*文件路径的文本框*@
        <label style="float:left;">请选择Excel文件：<input id="txt_Path" type="text" class="input-text upload-url radius" style="width:700px" onclick="$('input[id=fileUpload]').click();"></label>
        <input id="fileUpload" type="file" name="file" style="display:none;" />
        @*浏览本地文件按钮*@
        <span id="btn_Browse" style="cursor:pointer;" onclick="$('input[id=fileUpload]').click();" class="btn btn-primary radius">
            <i class="Hui-iconfont-pages"></i>浏览文件
        </span>
    </div>
}

<button type="button" id="go" class="btn primary radius" onclick="AddAll()">开始上传</button>


<div style="margin-top:15px;">
    <table class="table table-border radius" style="width:100%">
        <thead>
            <tr class="text-c">
                <td>@Html.DisplayNameFor(n => n.Student_Numb)</td>
                <td>@Html.DisplayNameFor(n => n.Student_Pass)</td>
                <td>@Html.DisplayNameFor(n => n.Student_Name)</td>
                <td>@Html.DisplayNameFor(n => n.Student_Email)</td>
                <td>@Html.DisplayNameFor(n => n.Student_Tel)</td>
                <td>@Html.DisplayNameFor(n => n.Student_Card)</td>
                <td>@Html.DisplayNameFor(n => n.Student_Sex)</td>
                <td>@Html.DisplayNameFor(n => n.Lecturer_Name)</td>
                <td>@Html.DisplayNameFor(n => n.Class_Name)</td>
            </tr>
        </thead>
        <tbody class="text-c">
            @if (ViewBag.list != null)
            {
                foreach (var item in (ViewBag.list as IEnumerable<Student>).Take(10))
                {
                    <tr>
                        <td>@Html.DisplayFor(model => item.Student_Numb)</td>
                        <td>@Html.DisplayFor(model => item.Student_Pass)</td>
                        <td>@Html.DisplayFor(model => item.Student_Name)</td>
                        <td>@Html.DisplayFor(model => item.Student_Email)</td>
                        <td>@Html.DisplayFor(model => item.Student_Tel)</td>
                        <td>@Html.DisplayFor(model => item.Student_Card)</td>
                        <td>@Html.DisplayFor(model => item.Student_Sex)</td>
                        <td>@Html.DisplayFor(model => item.Lecturer_Name)</td>
                        <td>@Html.DisplayFor(model => item.Class_Name)</td>
                    </tr>
                }
            }
        </tbody>
    </table>
    <p class="text-r" style="color:red; margin-right:50px;">预览前10条</p>
</div>
<script type="text/javascript" src="~/Content/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="~/Content/lib/layer/2.4/layer.js"></script>
<script src="~/Content/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="~/Content/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="~/Content/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
@section scripts{
    <style type="text/css">
        #btn_Browse:hover {
            color: #3C763D;
        }
    </style>
    <script type="text/javascript">
        $('input[id=fileUpload]').change(function () {
            $('#txt_Path').val($(this).val());
            $('#form_Upload').submit();
        });
    </script>

    <script type="text/javascript">
        function AddAll() {
            $.ajax({
                url: '/SysUserInfo/AddAll?list=@(Session["list"] = ViewBag.list))',
                type: "Get",
                success: function (obj) {
                    if (obj > 0) {
                        alert('导入成功');
                        location.href = '/SysUserInfo/StudentShow';
                    }
                }
            })
        }
</script>



}

